package day05.regularExpression;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/25
 * 3.请使用代码描述：有一段文本 "  anglebaby 女    18     515151511  "
 * 分别描述一个人的姓名 性别 年龄(int) 和QQ号码信息,完成如下需求:
 * 1）、创建一个Person类,包含姓名,性别,年龄和QQ号码属性,使用解析出来信息创建一个Person对象,
 * 并打印这个人信息
 * 2）、并判断QQ号是否合法,匹配规则,全部都是数字,第一位非0,长度为5到12位
 */
public class Test3 {
    public static void main(String[] args) {
        String text  = "  anglebaby 女    18     515151511  ";
        String[] words = text.trim().split("\\s+");
        if(qqIsValid(words[3])){
            Person person = new Person();
            person.setName(words[0]);
            person.setGender(words[1].charAt(0));
            person.setAge(Integer.parseInt(words[2]));
            person.setQq(words[3]);
            System.out.println(person.getName()+"的个人信息：");
            System.out.println("性别："+person.getGender());
            System.out.println("年龄："+person.getAge());
            System.out.println("qq号码："+person.getQq());

        }
        }

    public static boolean qqIsValid(String qqNumber) {
        String regex = "[1-9][\\d]{4,11}";
        if (qqNumber.matches(regex)) {
            return true;
        }
        return false;
    }


    }


class Person{
    private String name;
    private int age;
    private char gender;
    private String qq;


    public Person() {
    }

    public Person(String name, int age, char gender, String qq) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.qq = qq;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return gender
     */
    public char getGender() {
        return gender;
    }

    /**
     * 设置
     * @param gender
     */
    public void setGender(char gender) {
        this.gender = gender;
    }

    /**
     * 获取
     * @return qq
     */
    public String getQq() {
        return qq;
    }

    /**
     * 设置
     * @param qq
     */
    public void setQq(String qq) {
        this.qq = qq;
    }

    public String toString() {
        return "Person{name = " + name + ", age = " + age + ", gender = " + gender + ", qq = " + qq + "}";
    }
}
